package com.example.demo.controller;

import com.example.demo.entity.Channel;
import com.example.demo.service.RedisRssService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * redis 订阅
 */
@RestController
@RequestMapping("rss-redis")
public class RedisController {
    @Autowired
    private RedisRssService rssService;
    @GetMapping("isAllRss")
    @ApiOperation("订阅所有频道")
    public boolean isAllRss(Integer state){
        return rssService.isAllRss(state);
    }
    @PostMapping("start")
    @ApiOperation("批量订阅频道")
    public boolean start(Integer state,@RequestBody List<Channel> rediss){
        return rssService.start(rediss);
    }
    @PostMapping("stop")
    @ApiOperation("批量取消频道")
    public boolean stop(Integer state,@RequestBody List<Channel> rediss){
        return rssService.stop(rediss);
    }
    @GetMapping("allState")
    @ApiOperation("所有频道的订阅状态")
    public List<Channel> allState(){
        return rssService.allState();
    }
    @PostMapping("state")
    @ApiOperation("频道的订阅状态")
    public List<Channel> state(@RequestBody List<Channel> rediss){
        return rssService.state(rediss);
    }

}
